package testcase.validationtest;

import junit.framework.TestCase;
import validation.*;
import card.Card;
import card.Cardset;

public class TrioChainTest extends TestCase{
	private Type trioChain;
	private Cardset cardset;
	@Override
	public void setUp(){
		trioChain = TrioChain.getInstance();
	}
	@Override
	public void tearDown(){
		trioChain.clear();
		trioChain=null;
	}
	// testcases
	public void testIdentifyMinCards(){
		cardset = new Cardset(6);
		cardset.clear();
		cardset.add(new Card('s','3'));
		cardset.add(new Card('c','3'));
		cardset.add(new Card('h','3'));
		cardset.add(new Card('d','4'));
		cardset.add(new Card('s','4'));
		cardset.add(new Card('d','4'));
		Type result = trioChain.identify(cardset);
		assertEquals(result, trioChain);
	}
	
	public void testIdentifyMaxCards(){
		cardset = new Cardset(18);
		cardset.clear();
		cardset.add(new Card('d','9'));
		cardset.add(new Card('h','9'));
		cardset.add(new Card('d','9'));
		cardset.add(new Card('s','X'));
		cardset.add(new Card('c','X'));
		cardset.add(new Card('h','X'));
		cardset.add(new Card('d','J'));
		cardset.add(new Card('s','J'));
		cardset.add(new Card('c','J'));
		cardset.add(new Card('h','Q'));
		cardset.add(new Card('d','Q'));
		cardset.add(new Card('s','Q'));
		cardset.add(new Card('c','K'));
		cardset.add(new Card('h','K'));
		cardset.add(new Card('d','K'));
		cardset.add(new Card('h','A'));
		cardset.add(new Card('d','A'));
		cardset.add(new Card('h','A'));
		Type result = trioChain.identify(cardset);
		assertEquals(result, trioChain);
	}
	
	public void testIdentifyCardChainWith2(){
		cardset = new Cardset(12);
		cardset.clear();
		cardset.add(new Card('s','Q'));
		cardset.add(new Card('c','Q'));
		cardset.add(new Card('h','Q'));
		cardset.add(new Card('d','K'));
		cardset.add(new Card('s','K'));
		cardset.add(new Card('c','K'));
		cardset.add(new Card('h','A'));
		cardset.add(new Card('c','A'));
		cardset.add(new Card('s','A'));
		cardset.add(new Card('h','2'));
		cardset.add(new Card('c','2'));
		cardset.add(new Card('s','2'));		
		Type result = trioChain.identify(cardset);
		assertEquals(result, null);
	}
	
	public void testIdentifyInsufficientCards(){
		cardset = new Cardset(4);
		cardset.clear();
		cardset.add(new Card('s','3'));
		cardset.add(new Card('c','3'));
		cardset.add(new Card('h','3'));
		cardset.add(new Card('d','4'));
		Type result = trioChain.identify(cardset);
		assertEquals(result, null);
	}
	
	public void testIdentifyCardChainAcrossBoundary(){
		cardset = new Cardset(9);
		cardset.clear();
		cardset.add(new Card('s','A'));
		cardset.add(new Card('c','A'));
		cardset.add(new Card('h','A'));
		cardset.add(new Card('d','2'));
		cardset.add(new Card('s','2'));
		cardset.add(new Card('c','2'));
		cardset.add(new Card('h','3'));
		cardset.add(new Card('d','3'));
		cardset.add(new Card('c','3'));
		Type result = trioChain.identify(cardset);
		assertEquals(result, null);
	}
	
	public void testPriorty_1(){
		cardset = new Cardset(6);
		cardset.clear();
		cardset.add(new Card('s','3'));
		cardset.add(new Card('c','3'));
		cardset.add(new Card('h','3'));
		cardset.add(new Card('d','4'));
		cardset.add(new Card('s','4'));
		cardset.add(new Card('d','4'));
		Cardset temp = new Cardset(6);
		temp.add(new Card('s','4'));
		temp.add(new Card('d','4'));
		temp.add(new Card('h','4'));
		temp.add(new Card('d','5'));
		temp.add(new Card('s','5'));
		temp.add(new Card('s','5'));		
		trioChain.lessPriorityThan(cardset);
		boolean result = trioChain.lessPriorityThan(temp);
		assertEquals(result, true);
	}
	
	public void testPriorty_2(){
		cardset = new Cardset(9);
		cardset.clear();
		cardset.add(new Card('s','3'));
		cardset.add(new Card('c','3'));
		cardset.add(new Card('h','3'));
		cardset.add(new Card('d','4'));
		cardset.add(new Card('s','4'));
		cardset.add(new Card('h','4'));
		cardset.add(new Card('d','5'));
		cardset.add(new Card('h','5'));
		cardset.add(new Card('c','5'));
		Cardset temp = new Cardset(9);
		temp.add(new Card('s','Q'));
		temp.add(new Card('s','Q'));
		temp.add(new Card('d','Q'));
		temp.add(new Card('h','K'));
		temp.add(new Card('d','K'));
		temp.add(new Card('s','K'));
		temp.add(new Card('d','A'));
		temp.add(new Card('s','A'));
		temp.add(new Card('c','A'));
		trioChain.lessPriorityThan(cardset);
		boolean result = trioChain.lessPriorityThan(temp);
		assertEquals(result, true);
	}
	
	public void testPriorty_3(){
		cardset = new Cardset(6);
		cardset.clear();
		cardset.add(new Card('h','5'));
		cardset.add(new Card('d','5'));
		cardset.add(new Card('s','5'));
		cardset.add(new Card('h','6'));
		cardset.add(new Card('d','6'));
		cardset.add(new Card('c','6'));
		Cardset temp = new Cardset(6);
		temp.add(new Card('s','5'));
		temp.add(new Card('c','5'));
		temp.add(new Card('d','5'));
		temp.add(new Card('c','6'));
		temp.add(new Card('s','6'));
		temp.add(new Card('d','6'));
		trioChain.lessPriorityThan(cardset);
		boolean result = trioChain.lessPriorityThan(temp);
		assertEquals(result, false);
	}	
	
}
